#ifndef __LIB_DICTIONARY_H__
#define __LIB_DICTIONARY_H__

#include "libutilsbase.h"
#include <map>
#pragma warning(disable : 4251)

LIB_NS_BEGIN

class LIBAPI TDictionary
{
public:
	TDictionary( const tstring& name ) : m_name( name ) {}
	TDictionary() {}
	virtual ~TDictionary() {}

	typedef std::map < tstring, tstring > Data;
	typedef Data::const_iterator iterator;
	typedef iterator const_iterator;

	/// Get the name of the dictionary.
	tstring GetName() const { return m_name; }
	/// Return the number of key/value pairs.
	int32 Size() const { return m_data.size(); }

	/// Get a value as a string.
	tstring GetString( const tstring&, bool capitalize = false ) const;
	//throw( ConfigError, FieldConvertError );
	/// Get a value as a int32.
	int32 GetInt32( const tstring& ) const;
	//throw( ConfigError, FieldConvertError );
	/// Get a value as a double.
	double GetDouble( const tstring& ) const;
	//throw( ConfigError, FieldConvertError );
	/// Get a value as a bool
	bool GetBool( const tstring& ) const;
	//throw( ConfigError, FieldConvertError );
	/// Get a value as a day of week
	int32 GetDay( const tstring& ) const;
	//throw( ConfigError, FieldConvertError );

	/// Set a value from a string.
	void SetString( const tstring&, const tstring& );
	/// Set a value from a int.
	void SetInt32( const tstring&, int32 );
	/// Set a value from a double.
	void SetDouble( const tstring&, double );
	/// Set a value from a bool
	void SetBool( const tstring&, bool );
	/// Set a value from a day
	void SetDay( const tstring&, int32 );

	/// Check if the dictionary contains a value for key.
	bool Has( const tstring& ) const;
	/// Merge two dictionaries.
	void Merge( const TDictionary& );

	iterator Begin() const { return m_data.begin(); }
	iterator End() const { return m_data.end(); }

private:
	Data m_data;
	tstring m_name;
};

LIB_NS_END

#endif //__LIB_DICTIONARY_H__
